<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>我的工作</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
</head>

<body>

    <div class="layui-fluid" id="LAY-app-message">
        <div class="layui-card">
            <div style="padding: 20px;">
                <button id="refresh-btn" class="layui-btn layui-btn-primary layui-btn-sm">刷新</button>
            </div>
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">巡检<span id="badge1" class="layui-badge">0</span></li>
                    <li>缺陷<span id="badge2" class="layui-badge">0</span></li>
                    <li>维修<span id="badge3" class="layui-badge">0</span></li>
                    <li>任务<span id="badge4" class="layui-badge">0</span></li>
                    <li>专项<span id="badge5" class="layui-badge">0</span></li>
                </ul>

                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">待处理</li>
                                <li>已处理</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="patrol-table1" lay-filter="task-table"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="patrol-table2" lay-filter="task-table"></table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">待处理</li>
                                <li>已处理</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="fault-table1" lay-filter="task-table"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="fault-table2" lay-filter="task-table"></table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">待处理</li>
                                <li>已处理</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="repair-table1" lay-filter="task-table"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="repair-table2" lay-filter="task-table"></table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">待处理</li>
                                <li>已处理</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="work-task-table1" lay-filter="task-table"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="work-task-table2" lay-filter="task-table"></table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-tab-item">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">待处理</li>
                                <li>已处理</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table id="maintain-table1" lay-filter="task-table"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table id="maintain-table2" lay-filter="task-table"></table>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <script type="text/html" id="toolbar-operation">
    <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
</script>
    <script src="/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'form'], function () {

            var table = layui.table;
            var $ = layui.$;

            table.render({
                elem: '#patrol-table1',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { type: 'checkbox' },
                    {
                        title: '序号', width: 60, templet: function (d) {
                            return d.LAY_TABLE_INDEX + 1;
                        }
                    },
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'patrol',
                    state: 1
                },
                page: true,
                done: function (res, curr, count) {
                    if (count > 0) {
                        $('#badge1').show();
                        $('#badge1').text(count);
                    } else {
                        $('#badge1').hide();
                    }
                }
            });

            table.render({
                elem: '#patrol-table2',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { field: 'completeTime', title: '完成时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'patrol',
                    state: 2
                },
                page: true
            });

            table.render({
                elem: '#fault-table1',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'fault',
                    state: 1
                },
                page: true,
                done: function (res, curr, count) {
                    if (count > 0) {
                        $('#badge2').show();
                        $('#badge2').text(count);
                    } else {
                        $('#badge2').hide();
                    }
                }
            });

            table.render({
                elem: '#fault-table2',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { field: 'completeTime', title: '完成时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'fault',
                    state: 2
                },
                page: true
            });

            table.render({
                elem: '#repair-table1',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'repair',
                    state: 1
                },
                page: true,
                done: function (res, curr, count) {
                    if (count > 0) {
                        $('#badge3').show();
                        $('#badge3').text(count);
                    } else {
                        $('#badge3').hide();
                    }
                }
            });

            table.render({
                elem: '#repair-table2',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { field: 'completeTime', title: '完成时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'repair',
                    state: 2
                },
                page: true
            });

            table.render({
                elem: '#work-task-table1',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'work-task',
                    state: 1
                },
                page: true,
                done: function (res, curr, count) {
                    if (count > 0) {
                        $('#badge4').show();
                        $('#badge4').text(count);
                    } else {
                        $('#badge4').hide();
                    }
                }
            });

            table.render({
                elem: '#work-task-table2',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { field: 'completeTime', title: '完成时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'work-task',
                    state: 2
                },
                page: true
            });

            table.render({
                elem: '#maintain-table1',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'maintain',
                    state: 1
                },
                page: true,
                done: function (res, curr, count) {
                    if (count > 0) {
                        $('#badge5').show();
                        $('#badge5').text(count);
                    } else {
                        $('#badge5').hide();
                    }
                }
            });

            table.render({
                elem: '#maintain-table2',
                url: 'my-tasks',
                title: '',
                skin: 'line',
                cols: [[
                    { field: 'name', title: '任务名称', width: 300 },
                    { field: 'createTime', title: '创建时间', width: 300 },
                    { field: 'completeTime', title: '完成时间', width: 300 },
                    { fixed: 'right', title: '操作', toolbar: '#toolbar-operation', width: 200 }
                ]],
                where: {
                    tag: 'maintain',
                    state: 2
                },
                page: true
            });

            table.on('tool(task-table)', function (obj) {
                var data = obj.data;
                if (data.page) {
                    window.location.href = data.page;
                } else {
                    layer.msg('请在移动端打开');
                }
            });

            $('#refresh-btn').on('click', function () {
                table.reload('patrol-table1');
                table.reload('patrol-table2');
                table.reload('fault-table1');
                table.reload('fault-table2');
                table.reload('repair-table1');
                table.reload('repair-table2');
                table.reload('work-task-table1');
                table.reload('work-task-table2');
                table.reload('maintain-table1');
                table.reload('maintain-table2');
            });

        });
    </script>

</html>